import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
const { t } = useI18n() // 国际化
// 表单校验
export const rules = reactive({
    tabl: [{ required: true, message: "表不能为空", trigger: "blur" }],
})
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
    {
      label: '编号',
      field: 'id',
      type: 'index',
      form: {
         show: false
      },
      detail: {
         show: false
      }
    },
    {
      label: '时间',
      field: 'rTime',
      form: {
          show: true,
          component: 'DatePicker',
          componentProps: {
              type: 'datetime',
              valueFormat: 'YYYY-MM-DD HH:mm:ss'
          }
      },
      search: {
         show: true,
         component: 'DatePicker',
         componentProps: {
             type: 'datetimerange',
             valueFormat: 'YYYY-MM-DD HH:mm:ss'
         }
      }
    },
    {
      label: '表',
      field: 'tabl',
      form: {
          show: true,
      },
      search: {
         show: true
      }
    },
    {
      label: '字段',
      field: 'lable',
      form: {
          show: true,
      },
      search: {
         show: true
      }
    },
    {
      label: '数值',
      field: 'value',
      form: {
          show: true,
      },
      search: {
         show: true
      }
    },
    {
        label: t('table.action'),
        field: 'action',
        width: '240px',
        form: {
            show: false
        },
        detail: {
            show: false
        }
    }
])

export const { allSchemas } = useCrudSchemas(crudSchemas)